$(function () {
  $(".header-box .nev-icon-box").click(function () {
    if ($(this).hasClass("active")) {
      $(this).removeClass("active");
      $("body").css({ height: "auto", overflow: "auto" });
      $(".header-box .logo_box").css({
        "background-color": "rgba(0, 0, 0, 0)",
      });
      var _windowScrollTop = $(window).scrollTop();
      if (_windowScrollTop < 120) {
        $(".header-box ").css({
          height: "16vw",
          "background-color": "rgba(0, 0, 0, 0)",
        });
      }
      if (_windowScrollTop > 120) {
        $(".header-box ").css({
          height: "16vw",
          "background-color": "rgba(0, 0, 0, 0.2)",
        });
      }
      if (_windowScrollTop > 180) {
        $(".back-top-box").fadeIn();
        $(".header-box ").css({
          height: "16vw",
          "background-color": "rgba(0, 0, 0, 0.35)",
        });
      }
      if (_windowScrollTop > 240) {
        $(".header-box ").css({
          height: "16vw",
          "background-color": "rgba(0, 0, 0, 0.5)",
        });
      }
      if (_windowScrollTop > 300) {
        $(".header-box ").css({
          height: "16vw",
          "background-color": "rgba(0, 0, 0, 0.65)",
        });
      }
      if (_windowScrollTop > 360) {
        $(".header-box ").css({
          height: "16vw",
          "background-color": "rgba(0, 0, 0, 0.8)",
        });
      }
      if (_windowScrollTop < 240) {
        $(".back-top-box").fadeOut();
      }
    } else {
      $(this).addClass("active");
      $("body").css({ height: "100vh", overflow: "hidden" });
      $(".header-box").css({
        height: "100vh",
        "background-color": "rgba(0, 0, 0, 0.3)",
      });
      $(".header-box .logo_box").css({
        "background-color": "rgba(0, 0, 0, 0.8)",
      });
    }
  });
  $("body").bind("keyup", function (event) {
    if (event.keyCode == 13) {
      var _val = $("#searchBox").val();
      location.href='/wap/self.html?keyword='+escape(_val);
    }
  });
  $(".search_btn").click(function () {
    var _val = $("#searchBox").val();
    location.href='/wap/self.html?keyword='+escape(_val);
  });

  // 返回顶部
  $(".back-top-box").click(function () {
    $("body,html").animate({ scrollTop: 0 }, 500);
  });

  //   监听页面滚动
  $(window).scroll(function () {
    var _scrollTop = $(this).scrollTop();

    if (_scrollTop < 120) {
      $(".header-box ").css({ "background-color": "rgba(0, 0, 0, 0)" });
    }
    if (_scrollTop > 120) {
      $(".header-box ").css({ "background-color": "rgba(0, 0, 0, 0.2)" });
    }
    if (_scrollTop > 180) {
      $(".back-top-box").fadeIn();
      $(".header-box ").css({ "background-color": "rgba(0, 0, 0, 0.35)" });
    }
    if (_scrollTop > 240) {
      $(".header-box ").css({ "background-color": "rgba(0, 0, 0, 0.5)" });
    }
    if (_scrollTop > 300) {
      $(".header-box ").css({ "background-color": "rgba(0, 0, 0, 0.65)" });
    }
    if (_scrollTop > 360) {
      $(".header-box ").css({ "background-color": "rgba(0, 0, 0, 0.8)" });
    }
    if (_scrollTop < 240) {
      $(".back-top-box").fadeOut();
    }
  });
});
